﻿Imports System.IO
Imports System.Xml.Serialization
Imports System.ComponentModel

<XmlRoot("Settings")> _
Public Class GameProfile

#Region " Constructors "

    Public Sub New()
        Me.Name = ""
        Me.Icon = New Bitmap(16, 16)
        Me.MemoryCard1 = ""
        Me.MemoryCard2 = ""
        Me.DiscLocation = ""
        Me.PatchFile = ""
        Me.PadMode = 0
    End Sub

    Public Sub New(ByVal name As String)
        Me.New()
        Me.Name = name
    End Sub

#End Region

#Region " Properties "

    Private m_name As String
    Private m_icon As Bitmap
    Private m_memoryCard1 As String
    Private m_memoryCard2 As String
    Private m_discLocation As String
    Private m_patchFile As String
    Private m_padMod As Integer

    Public Property Name() As String
        Get
            Return m_name
        End Get
        Set(ByVal value As String)
            m_name = value
        End Set
    End Property

    <XmlIgnoreAttribute()> _
    Public Property Icon() As Bitmap
        Get
            Return m_icon
        End Get
        Set(ByVal value As Bitmap)
            m_icon = value
        End Set
    End Property

    <XmlElementAttribute("Icon")> _
    Public Property IconByteArray() As Byte()
        Get
            If m_icon IsNot Nothing Then
                Dim BitmapConverter As TypeConverter = TypeDescriptor.GetConverter(m_icon.GetType())
                Return CType(BitmapConverter.ConvertTo(m_icon, GetType(Byte())), Byte())
            Else
                Return Nothing
            End If
        End Get
        Set(ByVal value As Byte())
            If value IsNot Nothing Then
                m_icon = New Bitmap(New MemoryStream(value))
            Else
                m_icon = Nothing
            End If
        End Set
    End Property

    Public Property MemoryCard1() As String
        Get
            Return m_memoryCard1
        End Get
        Set(ByVal value As String)
            m_memoryCard1 = value
        End Set
    End Property

    Public Property MemoryCard2() As String
        Get
            Return m_memoryCard2
        End Get
        Set(ByVal value As String)
            m_memoryCard2 = value
        End Set
    End Property

    Public Property DiscLocation() As String
        Get
            Return m_discLocation
        End Get
        Set(ByVal value As String)
            m_discLocation = value
        End Set
    End Property

    Public Property PatchFile() As String
        Get
            Return m_patchFile
        End Get
        Set(ByVal value As String)
            m_patchFile = value
        End Set
    End Property

    Public Property PadMode() As Integer
        Get
            Return m_padMod
        End Get
        Set(ByVal value As Integer)
            m_padMod = value
        End Set
    End Property

#End Region

End Class
